class CQueue:

    def __init__(self):
        self.stack_in = []
        self.stack_out = []

    def appendTail(self, value: int) -> None:
        self.stack_in.append(value)

    def deleteHead(self) -> int:
        # 当 stack_out 不为空时, 直接出栈即可
        while len(self.stack_out) != 0:
            return self.stack_out.pop()

        if len(self.stack_in) == 0:
            return -1

        # 只有当 stack_out 空了, 并且需要有新的元素出栈, 而且 stack_in 不为空时, 才将 stack_in 的元素出栈, 并
        # 入栈到 stack_in
        while len(self.stack_in) != 0:
            self.stack_out.append(self.stack_in.pop())

        return self.stack_out.pop()


if __name__ == "__main__":
    queue = CQueue()
    queue.appendTail(3)
    queue.deleteHead()
    queue.deleteHead()

    queue = CQueue()
    queue.deleteHead()
    queue.appendTail(5)
    queue.appendTail(2)
    queue.deleteHead()
    queue.deleteHead()

    print("Done!")
